//
//  AppAndDeviceTool.m
//  ZCJZ
//
//  Created by sujeking on 2019/2/25.
//  Copyright © 2019年 jeking. All rights reserved.
//

#import "AppAndDeviceTool.h"

@import UIKit;
@import CoreTelephony;
//#import <CoreTelephony/CTTelephonyNetworkInfo.h>
//#import <CoreTelephony/CTCarrier.h>

@implementation AppAndDeviceTool

+ (instancetype)shareInstance {
    static AppAndDeviceTool *tool = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        tool = [[AppAndDeviceTool alloc] init];
    });
    return tool;
}

- (NSString *)appNameStr {
    NSDictionary *info = [[NSBundle mainBundle] infoDictionary];
    return [info valueForKey:@"CFBundleDisplayName"];
}

- (NSString *)appVersionStr {
    NSDictionary *info = [[NSBundle mainBundle] infoDictionary];
    return [info valueForKey:@"CFBundleShortVersionString"];
}

- (NSString *)deviceSystemVersionStr {
    NSString *version = [[UIDevice currentDevice] systemVersion];
    return version;
}

- (NSString *)deviceNameStr {
    NSString *name = [[UIDevice currentDevice] systemName];
    return name;
}

- (NSString *)deviceModelStr {
    NSString *model = [[UIDevice currentDevice] model];
    return model;
}

- (NSString *)deviceIdStr {
    NSString *idstr = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
    return idstr;
}

- (NSString *)channelStr {
#ifdef DEBUG
    return @"pgyer.com";
#else
    return @"AppStore";
#endif
}

- (NSString *)operatorStr {
    CTTelephonyNetworkInfo *info = [[CTTelephonyNetworkInfo alloc] init];
    CTCarrier *carrier = [info subscriberCellularProvider];
    //当前手机所属运营商名称
    NSString *mobile;
    //先判断有没有SIM卡，如果没有则不获取本机运营商
    if (!carrier.isoCountryCode) {
        NSLog(@"没有SIM卡");
        return @"无运营商";
    }else{
        return [carrier carrierName];
    }
}




@end
